package com.kehao.leetcode.jzoffer;

import org.junit.Test;

/**
 * @author Kehao.Chen
 * @version 1.0
 * @date 2022/6/24 17:48
 */
public class JZSolution032 {

    public boolean isAnagram(String s, String t) {
        int[] count = new int[26];
        if(s.length()!=t.length()){
            return false;
        }
        if(s.equals(t)){
            return false;
        }
        int length = s.length();
        for (int i = 0; i < length; i++) {
            count[s.charAt(i)-'a']++;
            count[t.charAt(i)-'a']--;
        }
        for (int i = 0; i < 26; i++) {
            if(count[i]!=0){
                return false;
            }
        }
        return true;

    }

    @Test
    public void test01(){
        String s = "a";
        String t = "a";
        boolean anagram = isAnagram(s, t);
        System.out.println(anagram);
    }
}
